For effective feature selection, a simple web search returned a list of regular
expressions that are mainly present in spam
e-mails\footnote{\url{http://wiki.spamihilator.com/doku.php?id=en:tutorials:regex}}.
After minor edits to these expressions, they could be used to effectively
distinguish spam from ham e-mail. The full list of features can be seen in
appendix \ref{app:bayes}.

\subsubsection{Automated Feature Selection}
A matlab script is also created, that is capable of selecting important
keywords. This script explains itself in appendix \ref{app:featureSelect}. The
output for this feature selection for $NHam = 50$ and $NSpam = 50$ is as
follows:
\begin{lstlisting}
   hamReturn = 
    'A'
    'AM'
    'AND'
    'ANY'
    'ARE'
    'AS'
    'AT'
    'BE'
    'BY'
    'CC'
    'FOR'
    'HAVE'
    'I'
    'IF'
    'IN'
    'IS'
    'KNOW'
    'LET'
    'ME'
    'NOT'
    'OF'
    'ON'
    'OR'
    'PLEASE'
    'SUBJECT'
    'THANKS'
    'THAT'
    'THE'
    'THIS'
    'TO'
    'WE'
    'WILL'
    'WITH'
    'WOULD'
    'XX'
spamReturn = 
    'HTTP'
\end{lstlisting}

As can be seen, more words are returned for $NHam = 50$ than $NSpam = 50$. This
could be because the e-mails that are usually marked as spam are about many
different subjects, whereas the ham e-mails are mostly about some of the same
subjects. Luckily we have the web-found regular expressions for spam-detection,
so we could just select some of the better words from ham for ham-detection.

Logic dictates that words like `the', `this' and `a' are bad choices. These
words are probably present because of the fact that our ham-corpus is slightly
larger than the spam-corpus. We can, however, select some better words by hand,
and use them in our algorithm. Most of the selected word are the less aggressive
words. We also considered the possibility of `let', `me', and `know' occurring
in order, most of the time. This resulted in the following regular expressions
being used in our bayesian algorithm, in collaboration with the other regular
expressions that were already used.:
\begin{lstlisting}
%Ham-specific:
'\slet\sme\sknow',
'\splease\s',
'\sthanks\s',
'\ssubject\s',
%Spam-specific:
'http',
\end{lstlisting}

The rest of the regular expressions is built up in a way that they mostly can handle capital and lower letter spelling and also in parts things like exchanged letters with numbers.
